﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.Controls;
using YArchitech.LIB;
using HYTextTool.CharacterIncrement.Forms;

namespace CharacterInc
{
	public partial class SelectWordForm : EscBaseForm
	{
		public bool GeneralForm(List<char> charact, List<bool> IsChange)
		{
			this.InitializeComponent();
			this.Chars = new char[charact.Count];
			base.Name = "Selectmodel";
			this.Text = "文字递增";
			base.Icon = Resource.YArchitechIcon;
			base.Size = new Size(40 * (charact.Count + 2) + 40, 150);
			base.MinimizeBox = false;
			base.MaximizeBox = false;
			base.ResumeLayout(false);
			base.FormBorderStyle = FormBorderStyle.FixedSingle;
			base.PerformLayout();
			bool flag = false;
			using (List<bool>.Enumerator enumerator = IsChange.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					if (enumerator.Current)
					{
						flag = true;
						break;
					}
				}
			}
			if (!flag)
			{
				YJKMessageBox.Show("没有可以递增的字符!");
				return false;
			}
			for (int i = 0; i < charact.Count; i++)
			{
				this.Chars[i] = charact[i];
				Button button = new Button();
				button.Name = "btn" + i;
				this.Btns.Add(button);
				if (IsChange[i])
				{
					Button button2 = new Button();
					button2.Click += this.ButtonClick;
					button2.Size = new Size(30, 30);
					string text = charact[i].ToString();
					button2.Tag = i;
					button2.Text = text;
					button2.Name = "btn" + i;
					button2.Location = new System.Drawing.Point(i * 40 + 20, 50);
					base.Controls.Add(button2);
				}
				else
				{
					Label label = new Label();
					label.AutoSize = true;
					label.Location = new System.Drawing.Point(i * 40 + 25, 60);
					label.Name = "label" + i;
					label.Size = new Size(20, 20);
					label.TabIndex = i;
					label.Text = charact[i].ToString();
					base.Controls.Add(label);
				}
			}
			return true;
		}

		private void ButtonClick(object sender, EventArgs e)
		{
			Button button = sender as Button;
			for (int i = 0; i < this.Btns.Count; i++)
			{
				if (button.Name == this.Btns[i].Name)
				{
					this.IncValue = i;
					break;
				}
			}
			base.Close();
		}

		public int IncValue = -1;

		private string[] Chinese = new string[10];

		private List<Button> Buttons = new List<Button>();

		private List<Button> Btns = new List<Button>();

		private List<Label> Labels = new List<Label>();

		private char[] Chars;
	}
}
